﻿/// <reference path="../Scripts/_references.js" />
$(document).ready(function () {

    $('#dialog').dialog({
        autoOpen: false,
        show: {
            effect: 'blind',
            duration: 1000
        },
        hide: {
            effect: 'blind',
            duration: 1000
        }
    });

    $('#Utilizadores').change(function () {
        var userid = $(this).val();
        if (userid === "") {
            return false;
        }
        var jornada_id = $('#routeDataId').val();
        $("#dialog").empty();
        $.getJSON('/Aposta/GetApostas', { id: userid, jornadaid: jornada_id }, function (data) {
            $.each(data, function (i, item) {
                var items = "<p>Jogo: " + item.HomeTeam + " - " + item.AwayTeam + "</p><p>Aposta: " + item.HomeBet + " - " + item.AwayBet + "</p>";
                $(items).appendTo('#dialog');
            });
            $("#dialog").dialog("open");
        });
    });

    //$('#btnApostar').on('Click', function () {
    //    var jornada_id = $(this).val();
    //    $.getJSON('/Aposta/Apostar', { id: jornada_id }, function (data) {
    //        //$.each(data, function (i, item) {
    //        //    var items = "<option value='" + item.Id + "'>" + item.Name + "</option>";
    //        //    $(items).appendTo(ddl_jornadas);
    //        //});
    //        console.log('success');
    //    })
    //    .done(function () { console.log('second success'); })
    //    .fail(function () { console.log("error"); })
    //    .always(function () { console.log("complete"); });
    //});

});